angular.module('Controller')
.controller('WIRaspberryManageNewCtrl', ($scope,NgTableParams,$localStorage,commonUtil,wfAlert,cryptUtil,commonConstant,$http, $uibModalInstance, items) ->
    $scope.type=type=items.type
    $scope.data=items.data
    $scope.modalTitle=if type=='new' then '新建账号' else '编辑账号'
    $scope.sexList=commonConstant.sexList()
    $scope.modalEnabledList=commonConstant.enabledList()
    $scope.newData=()->
        postData={
            accountId:$localStorage['accountId']
            uuid:$scope.data.uuid
            house:$scope.data.house
        }
        $http.post('@ostengar/raspberryPi',postData)
        .success((resp)->
            if resp.code == 0
                wfAlert.toastInfo('创建成功')
                $uibModalInstance.close('done')
            else
                wfAlert.toastError(resp.message)
        )

    $scope.judge=()->
        if type=='new'
            false
        else
            true
    $scope.confirm = ()->
        if type=='new'
            $scope.newData()
        else
            $scope.editData()
    $scope.cancel =()->
        $uibModalInstance.dismiss('cancel')

)